#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 100000

int main()
{
    vector<int> choose_dp;
    vector<int> nochoose_dp;
    vector<int> nums;
    int n;
    cin >> n;
    if (n == 0)
        return 0;
    nums.reserve(n);
    choose_dp.reserve(n);
    nochoose_dp.reserve(n);
    for(int i = 0 ; i < n; i++) cin >> nums[i];
    nochoose_dp[0] = 0, choose_dp[0] = nums[0];
    for (int i = 1 ; i < n; i++)
    {
        choose_dp[i] = nums[i] + nochoose_dp[i - 1];
        nochoose_dp[i] = max(choose_dp[i - 1], nochoose_dp[i - 1]);
        // cout << "i: "<< i << " " << choose_dp[i] << " " << nochoose_dp[i] << endl;
    }
    cout << max(nochoose_dp[n - 1], choose_dp[n - 1]) << endl;
    return 0;
}